﻿using HKB.Common;
using HKB.Web;
using HKB.Web.Shop;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Xml;

public partial class ProductList : Shop, IRequiresSessionState
{
    private Shop_Class _class = null;
    private int _returnDataCountForEach = 20;
    private int _allProductCount = -1;
    private int classid = 0;
    private string showProType = "";
    private string proTypeWhere = "";
    private int _listViewType = 2;
    private string _productName = "-1";
    private Dictionary<string, string> ParamList = new Dictionary<string, string>();
  
    protected Shop_Class m_class
    {
        get
        {
            Shop_Class @class;
            if (this._class == null)
            {
                this._class = new Shop_Class(this.conn);
                @class = this._class;
            }
            else
            {
                @class = this._class;
            }
            return @class;
        }
    }
    protected int ReturnDataCountForEach
    {
        get
        {
            return this._returnDataCountForEach;
        }
        set
        {
            this._returnDataCountForEach = value;
        }
    }
    protected int AllProductCount
    {
        get
        {
            int allProductCount;
            if (this._allProductCount != -1)
            {
                allProductCount = this._allProductCount;
            }
            else
            {
                string str = this.QueryStringParameter();
                List<IDbDataParameter> list = new List<IDbDataParameter>();
                if (this.ParamList.ContainsKey("beginprice"))
                {
                    list.Add(this.conn.CreateParameter("@BeginPrice", DbType.Decimal, this.ParamList["beginprice"]));
                    list.Add(this.conn.CreateParameter("@EndPrice", DbType.Decimal, this.ParamList["endprice"]));
                }
                if (this.ParamList.ContainsKey("Province"))
                {
                    list.Add(this.conn.CreateParameter("@Province", DbType.String, this.ParamList["Province"]));
                }
                if (this.ParamList.ContainsKey("city"))
                {
                    list.Add(this.conn.CreateParameter("@City", DbType.String, this.ParamList["city"]));
                }
                if (this.ParamList.ContainsKey("area"))
                {
                    list.Add(this.conn.CreateParameter("@Area", DbType.String, this.ParamList["area"]));
                }
                if (this.ParamList.ContainsKey("productname"))
                {
                    list.Add(this.conn.CreateParameter("@ProductName", DbType.String, this.ParamList["productname"]));
                }
                if (this.ParamList.ContainsKey("lable"))
                {
                    list.Add(this.conn.CreateParameter("@Goods_lbl", DbType.String, this.ParamList["lable"]));
                }
                IDbDataParameter[] array = null;
                if (list.Count > 0)
                {
                    array = list.ToArray();
                }
                string text = "";
                if (this.ParamList.ContainsKey("classid"))
                {
                    IDbDataParameter dbDataParameter = this.conn.CreateParameter("@ClassID", DbType.Int32, this.ParamList["classid"]);
                    text = this.conn.GetScalar("select [dbo].[GetChildrenClassIDByParentID](@ClassID)", new IDbDataParameter[]
					{
						dbDataParameter
					}).ToString();
                    if (text.Length > 0)
                    {
                        if (text[text.Length - 1] == ',')
                        {
                            text += this.ParamList["classid"];
                        }
                        else
                        {
                            text = this.ParamList["classid"];
                        }
                    }
                    else
                    {
                        text = this.ParamList["classid"];
                    }
                }
                DataTable dataTable;
                if (array == null)
                {
                    dataTable = this.conn.GetDataTable("select count(*) as AllCount\r\n                                                from dbo.HLShop_Product as a\r\n                                                join HLShop_ProductImg as j\r\n                                                on j.ProductID= a.ProductID\r\n                                                join HLShop_Shop  as h\r\n                                                on h.ShopID = a.ShopID  and a.EnableSale=1 and a.Stocks>0 and a.EnableSingleSell=1 and a.IsApprove=1  and a.EndDate>GETDATE()  and h.ShopStatus=1\r\n                                                join HL_User as g\r\n                                                on g.UserID=a.SalerID and g.IsLocked=0\r\n                                                join HL_UserInfo b\r\n                                                on a.SalerID = b.UserID " + str + ((text.Length > 0) ? (" and a.ClassID in (" + text + ") ") : ""));
                }
                else
                {
                    dataTable = this.conn.GetDataTable("select count(*) as AllCount\r\n                                                from dbo.HLShop_Product as a\r\n                                                join HLShop_Shop  as h\r\n                                                on h.ShopID = a.ShopID  and a.EnableSale=1 and a.Stocks>0 and a.EnableSingleSell=1 and a.IsApprove=1  and a.EndDate>GETDATE()  and h.ShopStatus=1\r\n                                                join HL_User as g\r\n                                                on g.UserID=a.SalerID and g.IsLocked=0\r\n                                                join HL_UserInfo b\r\n                                                on a.SalerID = b.UserID " + str + ((text.Length > 0) ? (" and a.ClassID in (" + text + ") ") : ""), array);
                }
                if (dataTable != null && dataTable.Rows.Count > 0)
                {
                    this._allProductCount = Convert.ToInt32(dataTable.Rows[0]["AllCount"]);
                }
                allProductCount = this._allProductCount;
            }
            return allProductCount;
        }
        set
        {
            this._allProductCount = value;
        }
    }
    public int Classid
    {
        get
        {
            string text = Fetch.Get("classid");
            int result;
            if (string.IsNullOrEmpty(text))
            {
                result = 0;
            }
            else
            {
                int num = 0;
                if (text.Length < 1)
                {
                    this.classid = 0;
                }
                else
                {
                    if (!int.TryParse(text, out num))
                    {
                        this.classid = 0;
                    }
                    else
                    {
                        this.classid = num;
                    }
                }
                result = this.classid;
            }
            return result;
        }
        set
        {
            this.classid = value;
        }
    }
    public new string ShowProType
    {
        get
        {
            if (base.Request.QueryString["showProType"] != null)
            {
                this.showProType = base.Request.QueryString["showProType"].ToString();
            }
            if (this.showProType != "")
            {
                this.showProType = string.Format("&showProType={0}", this.showProType);
            }
            return this.showProType;
        }
        set
        {
            this.showProType = value;
        }
    }
    public string ProTypeWhere
    {
        get
        {
            if (this.ShowProType == "5")
            {
                this.proTypeWhere = " and a.ProductType=5 ";
            }
            else
            {
                this.proTypeWhere = " and a.ProductType<>5 ";
            }
            return this.proTypeWhere;
        }
        set
        {
            this.proTypeWhere = value;
        }
    }
    public int ListViewType
    {
        get
        {
            int num = 0;
            if (base.Request.QueryString["viewtype"] != null && int.TryParse(base.Request.QueryString["viewtype"], out num))
            {
                if (num == 1)
                {
                    this._listViewType = 1;
                }
                else
                {
                    this._listViewType = 2;
                }
            }
            int listViewType;
            if (this._listViewType != 0)
            {
                listViewType = this._listViewType;
            }
            else
            {
                if (this.Classid <= 0)
                {
                    this._listViewType = 2;
                    listViewType = this._listViewType;
                }
                else
                {
                    DataTable dataTable = this.conn.GetDataTable("select ItemListOrderType,* from HLShop_Class where ClassID=" + this.Classid);
                    if (dataTable != null && dataTable.Rows.Count > 0)
                    {
                        this._listViewType = Convert.ToInt32(dataTable.Rows[0]["ItemListOrderType"]);
                    }
                    else
                    {
                        this._listViewType = 2;
                    }
                    listViewType = this._listViewType;
                }
            }
            return listViewType;
        }
    }
    public string OrderByFilter
    {
        get;
        set;
    }
    public string ProductName
    {
        get
        {
            string value = base.Request.QueryString["ProductName"];
            string productName;
            if (!string.IsNullOrEmpty(value))
            {
                value = this._productName;
                productName = this._productName;
            }
            else
            {
                productName = this._productName;
            }
            return productName;
        }
        set
        {
            this._productName = value;
        }
    }
    protected string TagName
    {
        get
        {
            string result;
            if (base.Request.QueryString["showProType"].IsNull(new object[0]).EndsWith("5"))
            {
                result = "积分兑换商品";
            }
            else
            {
                result = "所有商品";
            }
            return result;
        }
    }
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.IsPostBack)
        {
            this.GetProductList();
            this.BandList();
            this.GetPageLink();
            this.DefaultValue();
            this.GetEliteProduct();
            this.GetProLable();
        }
    }
    private void GetProLable()
    {
        string text = "";
        if (this.ParamList.ContainsKey("classid"))
        {
            IDbDataParameter dbDataParameter = this.conn.CreateParameter("@ClassID", DbType.Int32, this.ParamList["classid"]);
            text = this.conn.GetScalar("select [dbo].[GetChildrenClassIDByParentID](@ClassID)", new IDbDataParameter[]
			{
				dbDataParameter
			}).ToString();
            if (text.Length > 0)
            {
                if (text[text.Length - 1] == ',')
                {
                    text += this.ParamList["classid"];
                }
                else
                {
                    text = this.ParamList["classid"];
                }
            }
            else
            {
                text = this.ParamList["classid"];
            }
        }
        DataTable dataTable = this.conn.GetDataTable(string.Concat(new string[]
		{
			"select top 10 a.Goods_lbl,MAX(a.Hits) as HitCou \r\n                                            from HLShop_Product as a\r\n                                            join HLShop_Shop  as h\r\n                                            on h.ShopID = a.ShopID and a.EnableSale=1 and a.Stocks>0 and a.EnableSingleSell=1 and a.IsApprove=1 and a.Goods_lbl is not null \r\n                                            and a.Goods_lbl !='' ",
			this.ProTypeWhere,
			" and h.ShopStatus=1\r\n                                            join HLShop_ProductImg as j on j.ProductID= a.ProductID \r\n                                            join HL_User as g\r\n                                            on g.UserID=a.SalerID and g.IsLocked=0 ",
			(text.Length > 0) ? (" and a.ClassID in (" + text + ") ") : "",
			" group by a.Goods_lbl\r\n                                            order by HitCou Desc "
		}));
        if (dataTable != null && dataTable.Rows.Count > 0)
        {
            StringBuilder stringBuilder = new StringBuilder();
            int num = 0;
            foreach (DataRow dataRow in dataTable.Rows)
            {
                string text2 = dataRow["Goods_lbl"].ToString();
                string text3;
                if (text2.Length > 10)
                {
                    text3 = text2.Substring(0, 10) + "...";
                }
                else
                {
                    text3 = text2;
                }
                num += text3.Length;
                if (num <= 50)
                {
                    stringBuilder.AppendFormat(string.Concat(new object[]
					{
						"<a href='?classid=",
						this.Classid,
						"&showProType=",
						this.ShowProType,
						"&lable={0}'>{0}</a><span>|</span>"
					}), text3);
                }
            }
            this.ltrLables.Text = stringBuilder.ToString();
        }
    }
    public void BandList()
    {
        this.BindParentList();
        this.BindChildClass();
    }
    protected void BindParentList()
    {
        DataTable allParentClass = this.m_class.GetAllParentClass(this.Classid);
        this.ClassMapPath.DataSource = allParentClass;
        this.ClassMapPath.DataBind();
        allParentClass.Dispose();
        if (allParentClass != null && allParentClass.Rows.Count > 0)
        {
            string text = allParentClass.Rows[allParentClass.Rows.Count - 1]["ClassName"].ToString();
            if (text.Length > 6)
            {
                text = text.Substring(0, 6) + "...";
            }
            this.Literal1.Text = text;
        }
    }
    protected void BindChildClass()
    {
        DataTable childClassByParnetID = this.m_class.GetChildClassByParnetID(this.Classid);
        foreach (DataRow dataRow in childClassByParnetID.Rows)
        {
            if (dataRow["ClassName"].ToString() == "服务商品" || dataRow["ClassName"].ToString() == "创美商品")
            {
                dataRow.Delete();
            }
        }
        this.rpChildCategory.DataSource = childClassByParnetID;
        this.rpChildCategory.DataBind();
        childClassByParnetID.Dispose();
    }
    private void GetEliteProduct()
    {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.Append(" select top 6 ProductID,ProductImageUrl,ProductName,StandPrice,");
        stringBuilder.Append(" NeedPresentExp, ");
        stringBuilder.Append(" (select sum(Quantity) from dbo.HLShop_OrderItem as c ");
        stringBuilder.Append(" join HLShop_Order as d ");
        stringBuilder.Append(" on c.ProductID=a.ProductID and  c.OrderFormNum=d.OrderFormNum  and d.Status=2) ");
        stringBuilder.Append(" as SaleCount ");
        stringBuilder.Append(" from HLShop_Product as a ");
        stringBuilder.Append(" where EnableSale=1 and Stocks>0 and EnableSingleSell=1 and IsApprove=1  ");
        stringBuilder.Append(" and a.EndDate>GETDATE()  and IsElite=1 ");
        stringBuilder.AppendFormat(" {0} and  ProductSmallImageUrl is not null  ", this.ProTypeWhere);
        stringBuilder.Append(" and ProductSmallImageUrl !='' ");
        stringBuilder.Append(" order by OnTop Desc,IsHot Desc ");
        DataTable dataTable = this.conn.GetDataTable(stringBuilder.ToString());
        this.rptIsTopProduct.DataSource = dataTable;
        this.rptIsTopProduct.DataBind();
        dataTable.Dispose();
        for (int i = 0; i < this.rptIsTopProduct.Items.Count; i++)
        {
            Literal literal = (Literal)this.rptIsTopProduct.Items[i].FindControl("ltrIstopNeedPresentExp");
            HiddenField hiddenField = (HiddenField)this.rptIsTopProduct.Items[i].FindControl("hfIstopNeedPresentExp");
            if (literal != null)
            {
                if (this.ShowProType == "5")
                {
                    literal.Visible = true;
                    literal.Text = this.ExchangeScoreStrIsTop(hiddenField.Value);
                }
                else
                {
                    literal.Visible = false;
                }
            }
        }
    }
    private void DefaultValue()
    {
        this.ltrTopPage.Text = this.ValidateQueString().ToString() + "/" + ((this.AllProductCount + this.ReturnDataCountForEach - 1) / this.ReturnDataCountForEach).ToString();
        if (base.Request.QueryString["city"] != null && base.Request.QueryString["city"].Length > 0)
        {
            this.ltrCity.Text = base.Request.QueryString["city"];
        }
        int num = 0;
        if (base.Request.QueryString["nofare"] != null && int.TryParse(base.Request.QueryString["nofare"], out num))
        {
            this.NoFare.Checked = (num == 1);
        }
        else
        {
            this.NoFare.Checked = false;
        }
        if (base.Request.QueryString["sellprice"] != null)
        {
            string text = base.Request.QueryString["sellprice"];
            if (text.IndexOf("|") > 0)
            {
                string[] array = text.Split(new string[]
				{
					"|"
				}, StringSplitOptions.RemoveEmptyEntries);
                if (array.Length > 1 && int.TryParse(array[0], out num) && int.TryParse(array[1], out num))
                {
                    this.BeginPrice.Text = array[0];
                    this.EndPrice.Text = array[1];
                }
            }
        }
        if (base.Request.QueryString["sorttype"] != null && int.TryParse(base.Request.QueryString["sorttype"], out num))
        {
            switch (num)
            {
                case 2:
                    this.OrderByFilter = "2";
                    break;
                case 3:
                    this.OrderByFilter = "3";
                    break;
                case 4:
                    this.OrderByFilter = "4";
                    break;
                default:
                    this.OrderByFilter = "1";
                    break;
            }
        }
        else
        {
            this.OrderByFilter = "1";
        }
        if (this.ListViewType == 1)
        {
            this.SmallDataListDIV.Visible = true;
            this.BigDataListDIV.Visible = false;
        }
        else
        {
            this.SmallDataListDIV.Visible = false;
            this.BigDataListDIV.Visible = true;
        }
    }
    private void GetCurrentCity()
    {
    }
    private IDbDataParameter[] GetParameter(int PageIndex)
    {
        List<IDbDataParameter> list = new List<IDbDataParameter>();
        list.Add(this.conn.CreateParameter("@CurrentPage", DbType.Int32, PageIndex));
        list.Add(this.conn.CreateParameter("@PageSize", DbType.Int32, this.ReturnDataCountForEach));
        if (this.ParamList.ContainsKey("beginprice"))
        {
            list.Add(this.conn.CreateParameter("@BeginPrice", DbType.Decimal, this.ParamList["beginprice"]));
            list.Add(this.conn.CreateParameter("@EndPrice", DbType.Decimal, this.ParamList["endprice"]));
        }
        if (this.ParamList.ContainsKey("Province"))
        {
            list.Add(this.conn.CreateParameter("@Province", DbType.String, this.ParamList["Province"]));
        }
        if (this.ParamList.ContainsKey("city"))
        {
            list.Add(this.conn.CreateParameter("@City", DbType.String, this.ParamList["city"]));
        }
        if (this.ParamList.ContainsKey("area"))
        {
            list.Add(this.conn.CreateParameter("@Area", DbType.String, this.ParamList["area"]));
        }
        if (this.ParamList.ContainsKey("productname"))
        {
            list.Add(this.conn.CreateParameter("@ProductName", DbType.String, this.ParamList["productname"]));
        }
        if (this.ParamList.ContainsKey("lable"))
        {
            string text = this.ParamList["lable"].ToString();
            if (text.LastIndexOf("...") > 0)
            {
                text = text.Substring(0, text.LastIndexOf("..."));
            }
            list.Add(this.conn.CreateParameter("@Goods_lbl", DbType.String, text));
        }
        return list.ToArray();
    }
    private void GetProductList()
    {
        int pageIndex = this.ValidateQueString();
        string arg = this.QueryStringParameter();
        IDbDataParameter[] parameter = this.GetParameter(pageIndex);
        string text = "";
        if (this.ParamList.ContainsKey("classid"))
        {
            IDbDataParameter dbDataParameter = this.conn.CreateParameter("@ClassID", DbType.Int32, this.ParamList["classid"]);
            text = this.conn.GetScalar("select [dbo].[GetChildrenClassIDByParentID](@ClassID)", new IDbDataParameter[]
			{
				dbDataParameter
			}).ToString();
            if (text.Length > 0)
            {
                if (text[text.Length - 1] == ',')
                {
                    text += this.ParamList["classid"];
                }
                else
                {
                    text = this.ParamList["classid"];
                }
            }
            else
            {
                text = this.ParamList["classid"];
            }
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.Append(" select * from ");
        stringBuilder.Append(" ( ");
        stringBuilder.AppendFormat(" select *,ROW_NUMBER() over(order by {0} Desc) as number ", this.OrderBy());
        stringBuilder.Append(" from ( ");
        stringBuilder.Append(" select ( ");
        stringBuilder.Append(" select count(1) from HLMall_Credit where ValuerID=a.SalerID and CreditScore=1 and JustSBCredit=0) as Credit, ");
        stringBuilder.Append(" ( ");
        stringBuilder.Append(" select sum(Quantity) from dbo.HLShop_OrderItem as c ");
        stringBuilder.Append(" join HLShop_Order as d ");
        stringBuilder.Append(" on c.ProductID=a.ProductID and  c.OrderFormNum=d.OrderFormNum  and d.Status=2 ");
        stringBuilder.Append(" and (UpdateTime between DATEADD(DAY,-30,GETDATE()) and GETDATE())");
        stringBuilder.Append(" ) as SaleCount, ");
        stringBuilder.Append(" ( ");
        stringBuilder.Append(" select COUNT(1) from HLMall_Credit as e,HLShop_OrderItem as f ");
        stringBuilder.Append(" where e.OrderFormNum=f.OrderFormNum  and f.ProductID=a.ProductID) AllCommentCount, ");
        stringBuilder.Append(" a.ProductID,a.ProductName,a.DeliverType,a.BeginDate,a.EndDate,a.CurrentPrice,a.Hits, ");
        stringBuilder.Append(" a.StandPrice,a.ProductImageUrl,a.CreateTime,a.ShopID,a.SalerID,a.ProductType, ");
        stringBuilder.Append(" a.NeedPresentExp,a.Province,a.City, ");
        stringBuilder.Append(" b.OICQ,b.Taobaowangwang,h.ShopName,j.ImgPath1 from dbo.HLShop_Product as a ");
        stringBuilder.Append(" join HLShop_ProductImg as j on j.ProductID= a.ProductID ");
        stringBuilder.Append(" join HLShop_Shop  as h on h.ShopID = a.ShopID and a.EnableSale=1 and a.Stocks>=0 and a.EnableSingleSell=1 and a.IsApprove=1 and a.EndDate>GETDATE()  and h.ShopStatus=1 ");
        stringBuilder.Append(" join HL_User as g on g.UserID=a.SalerID and g.IsLocked=0 ");
        stringBuilder.AppendFormat(" join HL_UserInfo b on a.SalerID = b.UserID {0} {1} ) tempTable ", arg, (text.Length > 0) ? (" and a.ClassID in (" + text + ") ") : "");
        stringBuilder.Append(" ) as t ");
        stringBuilder.Append(" where t.number>(@CurrentPage-1)*@PageSize and t.number<=@CurrentPage*@PageSize ");
        DataTable dataTable = this.conn.GetDataTable(stringBuilder.ToString(), parameter);
        this.Repeater1.DataSource = dataTable;
        this.Repeater1.DataBind();
        this.DataList1.DataSource = dataTable;
        this.DataList1.DataBind();
        dataTable.Dispose();
        for (int i = 0; i < this.DataList1.Items.Count; i++)
        {
            Literal literal = (Literal)this.DataList1.Items[i].FindControl("ltrNeedPresentExp");
            HiddenField hiddenField = (HiddenField)this.DataList1.Items[i].FindControl("hfNeedPresentExp");
            if (literal != null)
            {
                if (this.ShowProType == "5")
                {
                    literal.Visible = true;
                    literal.Text = this.ExchangeScoreStr(hiddenField.Value, "2");
                }
                else
                {
                    literal.Visible = false;
                }
            }
        }
        for (int i = 0; i < this.Repeater1.Items.Count; i++)
        {
            Literal literal2 = (Literal)this.Repeater1.Items[i].FindControl("ltrSmallNeedPresentExp");
            HiddenField hiddenField2 = (HiddenField)this.Repeater1.Items[i].FindControl("hfSmallNeedPresentExp");
            if (literal2 != null)
            {
                if (this.ShowProType == "5")
                {
                    literal2.Visible = true;
                    literal2.Text = this.ExchangeScoreStr(hiddenField2.Value, "1");
                }
                else
                {
                    literal2.Visible = false;
                }
            }
        }
    }
    private string ExchangeScoreStr(string needPresentExp, string viewtype)
    {
        string result = "";
        if (!string.IsNullOrEmpty(needPresentExp))
        {
            if (needPresentExp != "0")
            {
                string text = "style='background-color:#6ca704;border: solid #6ca704; border-width: 1px; border-radius: 2px 2px 2px 2px;'";
                string text2 = "";
                if (viewtype == "2")
                {
                    text2 = "style=\"font-size: 12px;color:#ffffff;float:left;width:180px;text-align: left;padding-left: 6px;\"";
                }
                else
                {
                    if (viewtype == "1")
                    {
                        text2 = "style=\"font-size: 12px;color:#ffffff;float:left;width:auto;text-align: left;\"";
                    }
                }
                result = string.Concat(new string[]
				{
					"<div ",
					text2,
					"><span ",
					text,
					">换购积分：",
					needPresentExp,
					"分</span></div>"
				});
            }
        }
        return result;
    }
    private string ExchangeScoreStrIsTop(string needPresentExp)
    {
        string result = "";
        if (!string.IsNullOrEmpty(needPresentExp))
        {
            if (needPresentExp != "0")
            {
                string text = "style='background-color:#6ca704;border: solid #6ca704; border-width: 1px; border-radius: 2px 2px 2px 2px;color:#ffffff;'";
                string text2 = "style=\"font-size: 12px;float:left;width:auto;text-align: left;\"";
                result = string.Concat(new string[]
				{
					"<br><div ",
					text2,
					"><span ",
					text,
					">换购积分：",
					needPresentExp,
					"分</span></div>"
				});
            }
        }
        return result;
    }
    private string QueryStringParameter()
    {
        StringBuilder stringBuilder = new StringBuilder("");
        int num = 0;
        if (base.Request.QueryString["nofare"] != null && int.TryParse(base.Request.QueryString["nofare"], out num))
        {
            if (num == 1)
            {
                stringBuilder.Append(" and a.DeliverPayType=0 ");
            }
        }
        if (base.Request.QueryString["sellprice"] != null)
        {
            string text = base.Request.QueryString["sellprice"];
            decimal num2 = 0m;
            if (text.IndexOf("|") > 0)
            {
                string[] array = text.Split(new string[]
				{
					"|"
				}, StringSplitOptions.RemoveEmptyEntries);
                if (array.Length > 1 && decimal.TryParse(array[0], out num2) && decimal.TryParse(array[1], out num2))
                {
                    if (!this.ParamList.ContainsKey("beginprice"))
                    {
                        this.ParamList.Add("beginprice", array[0]);
                        this.ParamList.Add("endprice", array[1]);
                    }
                    stringBuilder.Append(" and (a.StandPrice between @BeginPrice and  @EndPrice) ");
                }
                else
                {
                    if (array.Length == 1 && decimal.TryParse(array[0], out num2))
                    {
                        if (!this.ParamList.ContainsKey("beginprice"))
                        {
                            this.ParamList.Add("beginprice", array[0]);
                            this.ParamList.Add("endprice", 2147483647.ToString());
                        }
                        stringBuilder.Append(" and (a.StandPrice between @BeginPrice and  @EndPrice) ");
                    }
                }
            }
        }
        if (base.Request.QueryString["Province"] != null && base.Request.QueryString["Province"].Length > 0)
        {
            if (!this.ParamList.ContainsKey("Province"))
            {
                this.ParamList.Add("Province", base.Request.QueryString["Province"].Trim());
            }
            stringBuilder.Append(" and a.Province like '%'+ @Province + '%' ");
        }
        if (base.Request.QueryString["city"] != null && base.Request.QueryString["city"].Length > 0)
        {
            if (!this.ParamList.ContainsKey("city"))
            {
                this.ParamList.Add("city", base.Request.QueryString["city"].Trim());
            }
            stringBuilder.Append(" and a.City like '%'+ @City + '%' ");
        }
        if (base.Request.QueryString["area"] != null && base.Request.QueryString["area"].Length > 0)
        {
            if (!this.ParamList.ContainsKey("area"))
            {
                this.ParamList.Add("area", base.Request.QueryString["area"].Trim());
            }
            stringBuilder.Append(" and a.Area like '%'+ @Area + '%' ");
        }
        if (base.Request.QueryString["productname"] != null && base.Request.QueryString["productname"].Length > 0)
        {
            if (!this.ParamList.ContainsKey("productname"))
            {
                this.ParamList.Add("productname", base.Request.QueryString["productname"].Trim());
            }
            stringBuilder.Append(" and a.ProductName like '%'+ @ProductName + '%' ");
        }
        if (base.Request.QueryString["classid"] != null && base.Request.QueryString["classid"] != "0" && int.TryParse(base.Request.QueryString["classid"], out num))
        {
            if (!this.ParamList.ContainsKey("classid"))
            {
                this.ParamList.Add("classid", base.Request.QueryString["classid"].Trim());
            }
        }
        if (Fetch.Get("lable") != string.Empty)
        {
            if (!this.ParamList.ContainsKey("lable"))
            {
                this.ParamList.Add("lable", Fetch.Get("lable").Trim());
            }
            stringBuilder.Append(" and  a.Goods_lbl like '%'+ @Goods_lbl +'%'  ");
        }
        if (!string.IsNullOrEmpty(this.ShowProType))
        {
            if (!this.ParamList.ContainsKey("showProType"))
            {
                this.ParamList.Add("showProType", this.ShowProType);
            }
            if (this.ShowProType.EndsWith("5"))
            {
                stringBuilder.Append(" and  a.ProductType=5  ");
            }
            else
            {
                stringBuilder.Append(" and  a.ProductType<>5  ");
            }
        }
        else
        {
            stringBuilder.Append(" and  a.ProductType<>5  ");
        }
        return stringBuilder.ToString();
    }
    public string OrderBy()
    {
        string text = "";
        int num = 0;
        if (base.Request.QueryString["sorttype"] != null && int.TryParse(base.Request.QueryString["sorttype"], out num))
        {
            switch (num)
            {
                case 2:
                    text += "  Hits  ";
                    break;
                case 3:
                    text += "  CurrentPrice  ";
                    break;
                case 4:
                    text += "  Credit  ";
                    break;
                default:
                    text += "  CreateTime  ";
                    break;
            }
        }
        else
        {
            text += " CreateTime  ";
        }
        return text;
    }
    private string GetPage(int yushu, int page, int last, int allpage)
    {
        string text = base.Request.Url.ToString().ToLower();
        int begin = text.LastIndexOf("page=");
        int deletePoint = this.GetDeletePoint(begin, text);
        string text2 = "";
        string text3 = base.Request.Url.AbsolutePath.Substring(1);
        string text4 = "&showProType=" + this.ShowProType;
        string text5 = string.Concat(new string[]
		{
			"?classid=",
			base.Request.QueryString["classid"],
			text4,
			"&nofare=",
			base.Request.QueryString["nofare"],
			"&sellprice=",
			base.Request.QueryString["sellprice"],
			"&viewtype=",
			base.Request.QueryString["viewtype"],
			"&sorttype=",
			base.Request.QueryString["sorttype"],
			"&productname=",
			base.Request.QueryString["productname"],
			"&city=",
			base.Request.QueryString["city"],
			"&area=",
			base.Request.QueryString["area"],
			"&lable=",
			Fetch.Get("lable")
		});
        for (int i = 1; i <= yushu; i++)
        {
            if (page == last && page != allpage && page % 10 != 0)
            {
                object obj = text2;
                text2 = string.Concat(new object[]
				{
					obj,
					"<li class='",
					(page == last + i - 1) ? "cur" : "",
					"'><a  href='",
					text3,
					text5,
					"&page=",
					last + i,
					"'>",
					last + i,
					"</a></li>"
				});
            }
            else
            {
                if (page == last && page == allpage)
                {
                    last -= 10;
                    object obj = text2;
                    text2 = string.Concat(new object[]
					{
						obj,
						"<li class='",
						(page == last + i) ? "cur" : "",
						"'><a  href='",
						text3,
						text5,
						"&page=",
						last + i,
						"'>",
						last + i,
						"</a></li>"
					});
                }
                else
                {
                    if (page == last && page != allpage && page % 10 == 0)
                    {
                        last -= 10;
                        object obj = text2;
                        text2 = string.Concat(new object[]
						{
							obj,
							"<li class='",
							(page == last + i - 1) ? "cur" : "",
							"'><a  href='",
							text3,
							text5,
							"&page=",
							last + i,
							"'>",
							last + i,
							"</a></li>"
						});
                    }
                    else
                    {
                        object obj = text2;
                        text2 = string.Concat(new object[]
						{
							obj,
							"<li class='",
							(page == last + i) ? "cur" : "",
							"'><a  href='",
							text3,
							text5,
							"&page=",
							last + i,
							"'>",
							last + i,
							"</a></li>"
						});
                    }
                }
            }
        }
        return text2;
    }
    private void GetPageLink()
    {
        string text = base.Request.Url.ToString().ToLower();
        int begin = text.LastIndexOf("page=");
        int deletePoint = this.GetDeletePoint(begin, text);
        string text2 = base.Request.Url.AbsolutePath.Substring(1);
        int num = this.ValidateQueString();
        int num2 = (this.AllProductCount + this.ReturnDataCountForEach - 1) / this.ReturnDataCountForEach;
        if (num2 == 0)
        {
            this.ltrPage.Text = "<li class='xyue'><a  href='javascript:;'>上一页</a></li><li class='xyue'><a  href='javascript:'>下一页</a></li>";
            this.ltrLastPage.Text = "<a class=\"list_li_231_a1\" href='javascript:;' >上一页</a>";
            this.ltrNextPage.Text = "<a class=\"list_li_231_a3\"  href='javascript:;'>下一页</a>";
        }
        else
        {
            if (num <= num2 && num > 0)
            {
                string text3 = "&showProType=" + this.ShowProType;
                string text4 = string.Concat(new string[]
				{
					"?classid=",
					base.Request.QueryString["classid"],
					text3,
					"&nofare=",
					base.Request.QueryString["nofare"],
					"&sellprice=",
					base.Request.QueryString["sellprice"],
					"&viewtype=",
					base.Request.QueryString["viewtype"],
					"&sorttype=",
					base.Request.QueryString["sorttype"],
					"&productname=",
					base.Request.QueryString["productname"],
					"&city=",
					base.Request.QueryString["city"],
					"&area=",
					base.Request.QueryString["area"],
					"&lable=",
					Fetch.Get("lable")
				});
                string text5 = "";
                text5 += ((num == 1) ? "<li class='xyue'><a  href='javascript:;'>上一页</a></li>" : string.Concat(new object[]
				{
					"<li class='xyue'><a  href='",
					text2,
					text4,
					"&page=",
					num - 1,
					"'>上一页</a></li>"
				}));
                this.ltrLastPage.Text = ((num == 1) ? "<a class=\"list_li_231_a1\" href='javascript:;' >上一页</a>" : string.Concat(new object[]
				{
					"<a  class=\"list_li_231_a1\"  href='",
					text2,
					text4,
					"&page=",
					num - 1,
					"'>上一页</a>"
				}));
                if (num > 0 && num <= 10)
                {
                    int yushu = (num2 / 10 > 0) ? 10 : num2;
                    text5 += this.GetPage(yushu, num, 0, num2);
                }
                else
                {
                    if (num > 10 && num <= 10 * (num2 / 10))
                    {
                        int last = 10 * (num / 10);
                        text5 += this.GetPage(10, num, last, num2);
                    }
                    else
                    {
                        if (num > 10 * (num2 / 10) && num <= num2)
                        {
                            int yushu = num2 % 10;
                            int last = 10 * (num2 / 10);
                            text5 += this.GetPage(yushu, num, last, num2);
                        }
                    }
                }
                if (num2 == num)
                {
                    text5 += "<li class='xyue'><a  href='javascript:'>下一页</a></li>";
                    this.ltrNextPage.Text = "<a class=\"list_li_231_a3\"  href='javascript:;'>下一页</a>";
                }
                else
                {
                    object obj = text5;
                    text5 = string.Concat(new object[]
					{
						obj,
						"<li class='xyue'><a  href='",
						text2,
						text4,
						"&page=",
						num + 1,
						"'>下一页</a></li>"
					});
                    this.ltrNextPage.Text = string.Concat(new object[]
					{
						"<a  class=\"list_li_231_a3\"  href='",
						text2,
						text4,
						"&page=",
						num + 1,
						"'>下一页</a>"
					});
                }
                this.ltrPage.Text = text5;
            }
        }
    }
    private int GetDeletePoint(int begin, string url)
    {
        int result = begin;
        if (begin > 0)
        {
            result = begin + 1;
            for (int i = begin + 1; i < url.Length; i++)
            {
                if (url[i] == '&')
                {
                    result = i;
                }
            }
        }
        return result;
    }
    private int ValidateQueString()
    {
        string text = base.Request.QueryString["page"];
        int num = 1;
        int result;
        if (!string.IsNullOrEmpty(text))
        {
            if (!int.TryParse(text, out num))
            {
                result = 1;
            }
            else
            {
                result = num;
            }
        }
        else
        {
            result = 1;
        }
        return result;
    }
    private string UrlLink()
    {
        string value = base.Request.Url.AbsolutePath.Substring(1);
        StringBuilder stringBuilder = new StringBuilder(value);
        string str = "&showProType=" + this.ShowProType;
        stringBuilder.Append("?classid=" + this.Classid.ToString() + str);
        if (this.NoFare.Checked)
        {
            stringBuilder.Append("&nofare=1");
        }
        else
        {
            stringBuilder.Append("&nofare=0");
        }
        if (base.Request.QueryString["sellprice"] != null)
        {
            stringBuilder.Append("&sellprice=" + base.Request.QueryString["sellprice"]);
        }
        return stringBuilder.ToString();
    }
    protected void MostPrice_Click(object sender, EventArgs e)
    {
        string value = base.Request.Url.AbsolutePath.Substring(1);
        StringBuilder stringBuilder = new StringBuilder(value);
        string str = "&showProType=" + this.ShowProType;
        stringBuilder.Append("?classid=" + this.Classid.ToString() + str);
        if (this.NoFare.Checked)
        {
            stringBuilder.Append("&nofare=1");
        }
        else
        {
            stringBuilder.Append("&nofare=0");
        }
        stringBuilder.Append(string.Concat(new string[]
		{
			"&sellprice=0|8&viewtype=1&sorttype=",
			base.Request.QueryString["sorttype"],
			"&city=",
			base.Request.QueryString["city"],
			"&area=",
			base.Request.QueryString["area"],
			"&page=1"
		}));
        base.Response.Redirect(stringBuilder.ToString());
    }
    protected void MiddlePrice_Click(object sender, EventArgs e)
    {
        string value = base.Request.Url.AbsolutePath.Substring(1);
        StringBuilder stringBuilder = new StringBuilder(value);
        string str = "&showProType=" + this.ShowProType;
        stringBuilder.Append("?classid=" + this.Classid.ToString() + str);
        if (this.NoFare.Checked)
        {
            stringBuilder.Append("&nofare=1");
        }
        else
        {
            stringBuilder.Append("&nofare=0");
        }
        stringBuilder.Append(string.Concat(new string[]
		{
			"&sellprice=8|30&viewtype=1&sorttype=",
			base.Request.QueryString["sorttype"],
			"&city=",
			base.Request.QueryString["city"],
			"&area=",
			base.Request.QueryString["area"],
			"&page=1"
		}));
        base.Response.Redirect(stringBuilder.ToString());
    }
    protected void SmallList_Click(object sender, EventArgs e)
    {
        string url = string.Concat(new string[]
		{
			this.UrlLink(),
			"&viewtype=1&sorttype=",
			base.Request.QueryString["sorttype"],
			"&city=",
			base.Request.QueryString["city"],
			"&area=",
			base.Request.QueryString["area"],
			"&page=",
			base.Request.QueryString["page"]
		});
        base.Response.Redirect(url);
    }
    protected void BigList_Click(object sender, EventArgs e)
    {
        string url = string.Concat(new string[]
		{
			this.UrlLink(),
			"&viewtype=2&sorttype=",
			base.Request.QueryString["sorttype"],
			"&city=",
			base.Request.QueryString["city"],
			"&area=",
			base.Request.QueryString["area"],
			"&page=",
			base.Request.QueryString["page"]
		});
        base.Response.Redirect(url);
    }
    protected void DefaultSort_Click(object sender, EventArgs e)
    {
        string url = string.Concat(new string[]
		{
			this.UrlLink(),
			"&viewtype=",
			base.Request.QueryString["viewtype"],
			"&sorttype=1&city=",
			base.Request.QueryString["city"],
			"&area=",
			base.Request.QueryString["area"],
			"&page=",
			base.Request.QueryString["page"]
		});
        base.Response.Redirect(url);
    }
    protected void HitsSort_Click(object sender, EventArgs e)
    {
        string url = string.Concat(new string[]
		{
			this.UrlLink(),
			"&viewtype=",
			base.Request.QueryString["viewtype"],
			"&sorttype=2&city=",
			base.Request.QueryString["city"],
			"&area=",
			base.Request.QueryString["area"],
			"&page=",
			base.Request.QueryString["page"]
		});
        base.Response.Redirect(url);
    }
    protected void PriceSort_Click(object sender, EventArgs e)
    {
        string url = string.Concat(new string[]
		{
			this.UrlLink(),
			"&viewtype=",
			base.Request.QueryString["viewtype"],
			"&sorttype=3&city=",
			base.Request.QueryString["city"],
			"&area=",
			base.Request.QueryString["area"],
			"&page=",
			base.Request.QueryString["page"]
		});
        base.Response.Redirect(url);
    }
    protected void CreditSort_Click(object sender, EventArgs e)
    {
        string url = string.Concat(new string[]
		{
			this.UrlLink(),
			"&viewtype=",
			base.Request.QueryString["viewtype"],
			"&sorttype=4&city=",
			base.Request.QueryString["city"],
			"&area=",
			base.Request.QueryString["area"],
			"&page=",
			base.Request.QueryString["page"]
		});
        base.Response.Redirect(url);
    }
    protected void SubmitPrice_Click(object sender, EventArgs e)
    {
        string value = base.Request.Url.AbsolutePath.Substring(1);
        StringBuilder stringBuilder = new StringBuilder(value);
        string str = "&showProType=" + this.ShowProType;
        stringBuilder.Append("?classid=" + this.Classid.ToString() + str);
        if (this.NoFare.Checked)
        {
            stringBuilder.Append("&nofare=1");
        }
        else
        {
            stringBuilder.Append("&nofare=0");
        }
        if (string.IsNullOrEmpty(this.BeginPrice.Text))
        {
            if (!string.IsNullOrEmpty(this.EndPrice.Text))
            {
                stringBuilder.Append("&sellprice=0|" + this.EndPrice.Text.Trim());
            }
        }
        else
        {
            if (!string.IsNullOrEmpty(this.EndPrice.Text))
            {
                stringBuilder.Append("&sellprice=" + this.BeginPrice.Text.Trim() + "|" + this.EndPrice.Text.Trim());
            }
            else
            {
                stringBuilder.Append(string.Concat(new object[]
				{
					"&sellprice=",
					this.BeginPrice.Text.Trim(),
					"|",
					2147483647
				}));
            }
        }
        stringBuilder.Append(string.Concat(new string[]
		{
			"&viewtype=",
			base.Request.QueryString["viewtype"],
			"&sorttype=",
			base.Request.QueryString["sorttype"],
			"&area=",
			base.Request.QueryString["area"],
			"&city=",
			base.Request.QueryString["city"],
			"&page=1"
		}));
        base.Response.Redirect(stringBuilder.ToString());
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string value = base.Request.Url.AbsolutePath.Substring(1);
        StringBuilder stringBuilder = new StringBuilder(value);
        string str = "&showProType=" + this.ShowProType;
        stringBuilder.Append("?classid=" + this.Classid.ToString() + str);
        if (this.NoFare.Checked)
        {
            stringBuilder.Append("&nofare=1");
        }
        else
        {
            stringBuilder.Append("&nofare=0");
        }
        if (string.IsNullOrEmpty(this.BeginPrice.Text.Trim()))
        {
            if (!string.IsNullOrEmpty(this.EndPrice.Text.Trim()))
            {
                stringBuilder.Append("&sellprice=0|" + this.EndPrice.Text.Trim());
            }
        }
        else
        {
            if (!string.IsNullOrEmpty(this.EndPrice.Text.Trim()))
            {
                stringBuilder.Append("&sellprice=" + this.BeginPrice.Text.Trim() + "|" + this.EndPrice.Text.Trim());
            }
            else
            {
                stringBuilder.Append(string.Concat(new object[]
				{
					"&sellprice=",
					this.BeginPrice.Text.Trim(),
					"|",
					2147483647
				}));
            }
        }
        stringBuilder.Append(string.Concat(new string[]
		{
			"&viewtype=",
			base.Request.QueryString["viewtype"],
			"&sorttype=",
			base.Request.QueryString["sorttype"],
			"&area=",
			base.Request.QueryString["area"],
			"&city=",
			base.Request.QueryString["city"],
			"&page=1"
		}));
        base.Response.Redirect(stringBuilder.ToString());
    }
    public string GetAuctionDeliverByUserIDTypeID(int UserID, int TypeID)
    {
        string result;
        if (UserID < 0 || TypeID < 0)
        {
            result = "";
        }
        else
        {
            DataTable dataTable = this.conn.GetDataTable(string.Concat(new object[]
			{
				"select * from HLShop_DeliverType where UserID=",
				UserID,
				" and TypeID=",
				TypeID
			}));
            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                string text = dataTable.Rows[0]["DeliverAraa"].ToString();
                if (!string.IsNullOrEmpty(text) && text != "")
                {
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.LoadXml(text);
                    XmlNodeList xmlNodeList = xmlDocument.SelectNodes("root/project/deliver");
                    IEnumerator enumerator = xmlNodeList.GetEnumerator();
                    try
                    {
                        if (enumerator.MoveNext())
                        {
                            XmlNode xmlNode = (XmlNode)enumerator.Current;
                            decimal num = 0m;
                            if (decimal.TryParse(xmlNode.Attributes["default"].Value, out num))
                            {
                                result = xmlNode.Attributes["default"].Value;
                                return result;
                            }
                            result = "未设置";
                            return result;
                        }
                    }
                    finally
                    {
                        IDisposable disposable = enumerator as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    result = "未设置";
                }
                else
                {
                    result = "未设置";
                }
            }
            else
            {
                result = "未设置";
            }
        }
        return result;
    }
    public string GetDeliverAndProvinceCity(string salerId, string deliverType, string province, string city)
    {
        string text = "邮费：" + this.GetAuctionDeliverByUserIDTypeID(Convert.ToInt32(salerId), Convert.ToInt32(deliverType));
        string text2 = province + city;
        string result = string.Concat(new string[]
		{
			"<strong>",
			text,
			"</strong><span class='product-moonsell'>",
			text2,
			"</span>"
		});
        if (text.Length == 4)
        {
            if (text2.Length >= 10)
            {
                result = string.Concat(new string[]
				{
					"<strong>",
					text,
					"</strong><br><span class='product-moonsell' style='float:left;'>",
					text2,
					"</span>"
				});
            }
        }
        else
        {
            if (text.Length == 5)
            {
                if (text2.Length >= 9)
                {
                    result = string.Concat(new string[]
					{
						"<strong>",
						text,
						"</strong><br><span class='product-moonsell' style='float:left;'>",
						text2,
						"</span>"
					});
                }
            }
            else
            {
                if (text.Length >= 6)
                {
                    if (text2.Length >= 8)
                    {
                        result = string.Concat(new string[]
						{
							"<strong>",
							text,
							"</strong><br><span class='product-moonsell' style='float:left;'>",
							text2,
							"</span>"
						});
                    }
                }
            }
        }
        return result;
    }
}
